#pragma once

#include <iostream>


#define Die(code)   \
    do              \
    {               \
        exit(code); \
    } while (0)

#define CONV(v) (struct sockaddr *)(v)
#define defaultsockfd -1
#define backbag 8 
#define defaultport 8080

// const std::string Sep = "\r\n";
// const std::string LineSep = " ";
// const std::string BlankLine = Sep;
enum 
{
    USAGE_ERR = 1,
    SOCKET_ERR,
    BIND_ERR,
    LISTEN_ERR,
    SUBMMIT_ERR
};

// r是true sep不为空  2 r是true sep为空 分割完了 3 r是false sep也为空
bool ParseOneLine(std::string &str, std::string *out, const std::string &sep)
{
    auto pos = str.find(sep);
    if (pos == std::string::npos)
        return false;
    *out = str.substr(0, pos);
    str.erase(0, pos + sep.size());
    return true;
}
bool SplitString(std::string header, const std::string& sep ,std::string *key, std::string* value)
{
     auto pos = header.find(sep);
    if (pos == std::string::npos)
        return false;
    *key = header.substr(0, pos);
    *value = header.substr(pos+sep.size());
    return true;

}